package cn.csc.module.distribute.controller.app.order;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.framework.common.pojo.PageResult;
import cn.csc.module.distribute.controller.app.order.vo.AppDistributeOrderAmountVO;
import cn.csc.module.distribute.controller.app.order.vo.AppDistributeOrderReqVO;
import cn.csc.module.distribute.controller.app.order.vo.AppDistributeOrderRespVO;
import cn.csc.module.distribute.service.order.DistributeOrderService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.PermitAll;
import javax.validation.Valid;

import static cn.csc.framework.common.pojo.CommonResult.success;
import static cn.csc.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * @author yql
 * @date 2025/4/24
 **/
@Api(tags = "APP用户 - 分销订单")
@RestController
@RequestMapping("/distribute/order")
@Validated
@Slf4j
public class AppDistributeOrderController {
    @Autowired
    private DistributeOrderService distributeOrderService;
    /**
     * 团队订单列表
     */
    @GetMapping("/pageList")
    @Operation(summary = "团队订单列表" , description = "买家的订单列表")
    public CommonResult<PageResult<AppDistributeOrderRespVO>> orderList(@Valid AppDistributeOrderReqVO pageVO) {
        pageVO.setUserId(getLoginUserId());
        log.info("[AppDistributeOrderController][orderList][AppDistributeOrderReqVO]{}",pageVO);
        PageResult<AppDistributeOrderRespVO> pageResult = distributeOrderService.selectAppOrderPage(pageVO);
        return success(pageResult);
    }
    /**
     * 买家的订单列表的金额数据统计
     */
    @GetMapping("/getAmt")
    @Operation(summary = "买家的订单列表的数据统计" , description = "买家的订单列表的数据统计")
    public CommonResult<AppDistributeOrderAmountVO> getAmt(@Valid AppDistributeOrderReqVO pageVO) {
        pageVO.setUserId(getLoginUserId());
        log.info("[AppDistributeOrderController][orderList][AppDistributeOrderReqVO]{}",pageVO);
        AppDistributeOrderAmountVO pageResult = distributeOrderService.selectSumAmount(pageVO);
        return success(pageResult);
    }
}
